package com.vrv.app.task;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;

import com.vrv.app.R;
import com.vrv.common.utils.ViewUtils;
import com.zxing.activity.CaptureActivity;

public class ShipCheckFormActivity extends Activity {

    private EditText codeExt;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.activity_ship_check_form);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.common_title);

        codeExt = (EditText) findViewById(R.id.codeExt);

        Button scanBtn = (Button) findViewById(R.id.qrscanbtn);
        scanBtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View paramView) {
                Intent openCameraIntent = new Intent(ShipCheckFormActivity.this, CaptureActivity.class);
                startActivityForResult(openCameraIntent, 0);
            }
        });

        Button searchBtn = (Button) findViewById(R.id.searchBtn);
        searchBtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View paramView) {
                ViewUtils.forward(ShipCheckFormActivity.this, com.vrv.app.task.ShipCheckActivity.class);
            }
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        // 处理扫描结果（在界面上显示）
        if (resultCode == RESULT_OK) {
            Bundle bundle = data.getExtras();
            String scanResult = bundle.getString("result");
            codeExt.setText(scanResult);
        }
    }
}
